import { inject } from 'vue';
import { confirmManager, $baseConfirm, $confirmDelete, $confirmWarning, $confirmInfo } from '@/utils/confirm';

export function useConfirm() {
  // 尝试从注入中获取，如果没有则使用默认的
  const baseConfirm = inject('$baseConfirm', $baseConfirm);
  const confirmDelete = inject('$confirmDelete', $confirmDelete);
  const confirmWarning = inject('$confirmWarning', $confirmWarning);
  const confirmInfo = inject('$confirmInfo', $confirmInfo);
  const manager = inject('$confirmManager', confirmManager);

  return {
    // 全局方法
    confirm: baseConfirm,
    confirmDelete,
    confirmWarning,
    confirmInfo,

    // 管理器方法
    setLoading: manager.setLoading.bind(manager),
    clear: manager.clear.bind(manager),
    getItems: manager.getItems.bind(manager),

    // 兼容旧版本的方法
    $baseConfirm: baseConfirm,
    $confirmDelete: confirmDelete,
    $confirmWarning: confirmWarning,
    $confirmInfo: confirmInfo
  };
} 